package com.buobao.oa.service;

import com.buobao.oa.dao.ProcessFlowDao;
import com.buobao.oa.entity.ProcessFlow;
import com.buobao.oa.utils.MybatisUtils;

import java.util.Map;

public class ProcessFlowService {
    public ProcessFlow selectProcessingByFormId(Long formId) {
        return (ProcessFlow) MybatisUtils.executeQuery(sqlSession -> {
            ProcessFlowDao processFlowDao = sqlSession.getMapper(ProcessFlowDao.class);
            return processFlowDao.selectProcessingByFormId(formId);
        });
    }

    public void update(ProcessFlow processFlow) {
        MybatisUtils.executeUpdate(sqlSession -> {
            ProcessFlowDao processFlowDao = sqlSession.getMapper(ProcessFlowDao.class);
            processFlowDao.update(processFlow);
            return null;
        });
    }

    public ProcessFlow selectNextByFormIdAndOrder(Map<String,Object> params) {
        return (ProcessFlow) MybatisUtils.executeQuery(sqlSession -> {
            ProcessFlowDao processFlowDao = sqlSession.getMapper(ProcessFlowDao.class);
            return processFlowDao.selectNextByFormIdAndOrder(params);
        });
    }
}
